//
//  GGContractController.m
//  ggtool
//  谓词搜索,未做说明,
//  Created by engfei on 2017/5/4.
//  Copyright © 2017年 GaiGai. All rights reserved.
//

#import "GGContactController.h"

#import <AddressBookUI/AddressBookUI.h>
#import <AddressBook/AddressBook.h>
#import <ContactsUI/ContactsUI.h>
#import <Contacts/Contacts.h>

@interface GGContactController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *titleArr;
@property (nonatomic, strong) NSArray *vcArr;

@end

@implementation GGContactController

- (NSArray *)titleArr {
    if (_titleArr == nil) {
        _titleArr = @[@"AddressBookUI", @"AddressBook", @"ContactsUI", @"Contacts"];
    }
    return _titleArr;
}

- (NSArray *)vcArr {
    if (_vcArr == nil) {
        _vcArr = @[@"GGContactABUIViewController", @"GGContactABViewController", @"GGContactUIViewController", @"GGContactViewController"];
    }
    return _vcArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    UITableView *tableview = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [self.view addSubview:tableview];
    self.tableView =  tableview;
    tableview.delegate = self;
    tableview.dataSource = self;
    
    
    
}

#pragma mark - UITableViewDataSour

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    cell.textLabel.text = self.titleArr[indexPath.row];
    cell.detailTextLabel.text = self.vcArr[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}



#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    UIViewController *vc = [[NSClassFromString(self.vcArr[indexPath.row]) alloc] init];
    vc.title = self.titleArr[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
    
}



@end
